home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
os2
/
adaptor.zip
/
ADAPT.ZIP
/
adaptor
/
examples
/
simple
/
prime.f
< prev
next >
Wrap
Text File
|
1993-06-17
|
658b
|
29 lines
C data parallel source program
program prime
integer n, s, k
logical*1 a(:)
!hpf$ distribute a(block)
print *, 'Input n for counting primes in range 2 to n : '
read *, n
allocate (a(1:n))
call cm_timer_clear (1)
call cm_timer_start (1)
a = .true.
a(1) = .false.
k = 2
do while (k*k .le. n)
a(k*k:n:k) = .false.
k = k + 1
do while (.not. a(k))
k = k + 1
end do
end do
s = count (a)
call cm_timer_stop (1)
print *, 'There are ',s,' primes until ', n
call cm_timer_print (1)
deallocate (a)
end